a tool for shared writing and social publishing
1import {
2 OAuthClientMetadata,
3 OAuthClientMetadataInput,
4} from "@atproto/oauth-client-node";
5const hostname =
6 process.env.NODE_ENV === "development"
7 ? "http://localhost:3000"
8 : "https://leaflet.pub";
9
10const scope = "atproto transition:generic transition:email";
11const localconfig: OAuthClientMetadataInput = {
12 client_id: `http://localhost/?redirect_uri=${encodeURI(`http://127.0.0.1:3000/api/oauth/callback`)}&scope=${encodeURIComponent(scope)}`,
13 client_name: `Leaflet`,
14 client_uri: hostname,
15 redirect_uris: [`http://127.0.0.1:3000/api/oauth/callback`],
16 grant_types: [`authorization_code`, `refresh_token`],
17 response_types: [`code`],
18 application_type: `web`,
19 scope,
20 token_endpoint_auth_method: `none`,
21 dpop_bound_access_tokens: true,
22};
23
24const prodconfig: OAuthClientMetadataInput = {
25 client_id: `${hostname}/api/oauth/metadata`,
26 client_name: `Leaflet`,
27 client_uri: hostname,
28 logo_uri: `${hostname}/logo.png`,
29 tos_uri: `${hostname}/legal?terms`,
30 policy_uri: `${hostname}/legal?privacy`,
31 redirect_uris:
32 process.env.NODE_ENV === "development"
33 ? [`http://127.0.0.1:3000/api/oauth/callback`]
34 : [`https://leaflet.pub/api/oauth/callback`],
35 grant_types: [`authorization_code`, `refresh_token`],
36 response_types: [`code`],
37 application_type: `web`,
38 scope,
39 token_endpoint_auth_method: `private_key_jwt`,
40 token_endpoint_auth_signing_alg: "ES256",
41 dpop_bound_access_tokens: true,
42 jwks_uri: `${hostname}/api/oauth/jwks`,
43};
44export const oauth_metadata =
45 process.env.NODE_ENV === "development" ? localconfig : prodconfig;